# -*- coding: utf-8 -*-

# @Project : UI_DDTFrameWork
# @Author  : Mr.Deng
# @Time    : 2021/9/21 23:39

from page import BasePage
from config.urlConfig import *

from selenium.webdriver.common.by import By


class BaiDuSearchPage(BasePage):
    """
    百度搜索页面类文件
    """
    searchInput = (By.ID, "kw")
    searchButton = (By.ID, "su")

    def open_search_url(self):
        """
        打开百度搜索页面
        :return:
        """
        self.driver.open_url(searchUrl)

    def input_search_value(self, value: str):
        """
        输入搜索值
        :param value: 搜索字段
        :return:
        """
        self.driver.send_keys(elementPath=self.searchInput, value=value)

    def click_search_button(self):
        """
        点击搜搜按钮
        :return:
        """
        self.driver.click(elementPath=self.searchButton)

    def get_search_title(self) -> str:
        """
        获取页面title，判断搜索结果
        :return:
        """
        return self.driver.get_page_title()
